using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace InduMall.Core.Models.Mapping
{
    public class DownloadMap : EntityTypeConfiguration<Download>
    {
        public DownloadMap()
        {
            // Primary Key
            this.HasKey(t => t.DownloadId);

            // Properties
            this.Property(t => t.DownloadId)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.DocumentName)
                .IsRequired()
                .HasMaxLength(32);

            this.Property(t => t.ImageUrl)
                .IsRequired()
                .HasMaxLength(255);

            this.Property(t => t.DocumentUrl)
                .IsRequired()
                .HasMaxLength(255);

            // Table & Column Mappings
            this.ToTable("Download");
            this.Property(t => t.DownloadId).HasColumnName("DownloadId");
            this.Property(t => t.DocumentName).HasColumnName("DocumentName");
            this.Property(t => t.ImageUrl).HasColumnName("ImageUrl");
            this.Property(t => t.DocumentUrl).HasColumnName("DocumentUrl");
            this.Property(t => t.CreatedDate).HasColumnName("CreatedDate");
            this.Property(t => t.Rank).HasColumnName("Rank");
        }
    }
}
